package com.yx.crawler.typedef;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class CrawlerUrl {
	
	private int currentDepth=0;
	
	private String title;

	private String userAgent="Mozilla/4.0 (compatible; MSIE 7.0; NT 5.1; GTB5; .NET CLR 2.0.50727; CIBA)";

	private String url;

	private boolean getMethod = true;

	private Map<String, String> params = null;

	private Map<String, Object> meta = new HashMap<String, Object>();

	private Map<String, String> cookie = null;

	private Policy policy = Policy.NONE;

	private CrawlerListener crawlerListener = null;
	
	public CrawlerUrl(String url, String title, CrawlerListener crawlerListener) {
		this.url = url;
		this.title = title;
		this.crawlerListener = crawlerListener;
	}

	public CrawlerUrl(String url, CrawlerListener crawlerListener) {
		this.url = url;
		this.crawlerListener = crawlerListener;
	}
	
	public int getCurrentDepth() {
		return currentDepth;
	}

	protected void setCurrentDepth(int currentDepth) {
		this.currentDepth = currentDepth;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getUrl() {
		return url;
	}

	public boolean isGetMethod() {
		return getMethod;
	}

	public void setGetMethod(boolean getMethod) {
		this.getMethod = getMethod;
	}

	public Map<String, String> getParams() {
		return params;
	}

	public void setParams(Map<String, String> params) {
		this.params = params;
	}

	public Map<String, Object> getMeta() {
		return meta;
	}

	public void setMeta(Map<String, Object> meta) {
		this.meta = meta;
	}
	public void meta(String key,Object value){
		this.meta.put(key, value);
	}
	public Object meta(String key){
		return this.meta.get(key);
	}

	public Policy policy() {
		return policy;
	}

	public void setPolicy(Policy policy) {
		this.policy = policy;
	}

	public void replaceCrawlerListener(CrawlerListener crawlerListener) {
		this.crawlerListener = crawlerListener;
	}

	public CrawlerListener getCrawlerListener() {
		return crawlerListener;
	}

	public String getUserAgent() {
		return userAgent;
	}

	public void setUserAgent(String userAgent) {
		this.userAgent = userAgent;
	}

	public Map<String, String> getCookie() {
		return cookie;
	}

	public void setCookie(Map<String, String> cookie) {
		this.cookie = cookie;
	}

}
